<#assign className = table.className>   
<#assign classNameLower = className?uncap_first> 
<template>
    <el-container>
        <el-header ref="headerSearch">
            <el-form :inline="true" :model="params" size="mini" @submit.native.prevent="onSubmit">
            <#list table.columns as column>
			<#if column.constantName != "ID" && column.constantName != "STATUS" && column.constantName != "CREATE_TIME" && column.constantName != "UPDATE_TIME">
			<#if column.haveRelTable==0>
				<el-form-item label="${column.columnAlias}:">
                    <el-input v-model="params.${column.relTableObj.classNameFirstLower}" clearable></el-input>
                </el-form-item>
			<#else>
				<el-form-item label="${column.columnAlias}:">
                    <el-input v-model="params.${column.columnNameLower}" clearable></el-input>
                </el-form-item>
			</#if>
			</#if>
			</#list>
                <el-form-item>
                    <el-button type="primary" native-type="submit" :loading="loading">查询</el-button>
                </el-form-item>
            </el-form>

            <div class="toolbar">
                <el-button size="mini" icon="el-icon-circle-plus-outline" @click="onAdd">添加</el-button>
                <el-button size="mini" icon="el-icon-edit-outline" @click="onUpdate">修改</el-button>
                <el-button size="mini" icon="el-icon-delete" @click="onDelete">删除</el-button>
                <!--
                <el-button size="mini" icon="el-icon-upload" @click="onUpload">上传</el-button>
                -->
            </div>
        </el-header>

        <el-main>
            <el-table
                    border
                    ref="table"
                    height="300"
                    highlight-current-row
                    size="mini"
                    :data="page.results"
                    @selection-change="handleSelectionChange"
                    v-loading="loading"
                    @row-dblclick="onUpdate"
            >
                <el-table-column type="selection" fixed="left" width="55"></el-table-column>
                <el-table-column show-overflow-tooltip type="index" width="50" :index="indexMethod" resizable></el-table-column>

            <#list table.columns as column>
			<#if column.constantName != "ID" && column.constantName != "STATUS" && column.constantName != "CREATE_TIME" && column.constantName != "UPDATE_TIME">
			<#if column.haveRelTable==0>
                <el-table-column show-overflow-tooltip label="${column.columnAlias}" width="100" resizable>
                    <template slot-scope="item">
                        {{item.row.${column.relTableObj.classNameFirstLower}}}
                    </template>
                </el-table-column>
			<#else>
                <el-table-column show-overflow-tooltip label="${column.columnAlias}" width="80" resizable>
                    <template slot-scope="item">
                        {{item.row.${column.columnNameLower}}}
                    </template>
                </el-table-column>
			</#if>
			</#if>
			</#list>
                <el-table-column show-overflow-tooltip label="更新时间" min-width="140" resizable>
                    <template slot-scope="item">
                        {{Util.myFormatTime(item.row.updateTime || item.row.createTime)}}
                    </template>
                </el-table-column>
            </el-table>
        </el-main>
        <el-footer ref="footer">
            <el-pagination
                    background
                    @current-change="handlePageChange"
                    @size-change="handleSizeChange"
                    :current-page="page.page.pageNum"
                    :page-size="page.page.numPerPage"
                    layout="total, sizes, prev, pager, next, jumper"
                    :total="page.page.totalCount">
            </el-pagination>
        </el-footer>

        <Modify ref="modify"/>
        <!--
        <my-upload ref="upload" :on-upload-success="onUploadSuccess"
                template-url="/template/xxx_template.xlsx"/>
        -->
    </el-container>
</template>

<script type="text/ecmascript-6">
    import Parent from '@/components/element/common/Retrieve';
    import Modify from './${className}Modify.vue';

    export default {
        name: '${className}',
        extends: Parent,
        components: {
            Modify
        },
        data() {
            let packageName = '${namespace}';
            let beanName = '${classNameLower}';
            let params = eval('this.$store.state.' + beanName + 'Page.params');

            return {
                packageName,
                beanName,
                params: {...params},
            }
        },
    }
</script>